home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / ptoc / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-07-26  |  33.3 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i066:  Pascal to C translator, Part02/12
  5. Message-ID: <705@uunet.UU.NET>
  6. Date: 27 Jul 87 23:06:45 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1546
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Per Bergsten <mcvax!enea!chalmers!holtec!perb>
  12. Posting-number: Volume 10, Issue 66
  13. Archive-name: ptoc/Part02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 12)."
  22. # Contents:  ptc.c.3
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'ptc.c.3' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'ptc.c.3'\"
  26. else
  27. echo shar: Extracting \"'ptc.c.3'\" \(30864 characters\)
  28. sed "s/^X//" >'ptc.c.3' <<'END_OF_FILE'
  29. X                break ;
  30. X              default:
  31. X                Caseerror(Line);
  32. X            }
  33. X            nextsymbol(*((symset *)Conset[91]));
  34. X            break ;
  35. X          case nparproc:
  36. X            tq->U.V15.tparid = newid(currsym.U.V1.vid);
  37. X            nextsymbol(*((symset *)Conset[92]));
  38. X            if (currsym.st == slpar) {
  39. X                enterscope((declptr)NIL);
  40. X                tq->U.V15.tparparm = psubpar();
  41. X                nextsymbol(*((symset *)Conset[93]));
  42. X                leavescope();
  43. X            } else
  44. X                tq->U.V15.tparparm = (struct S61 *)NIL;
  45. X            tq->U.V15.tpartyp = (struct S61 *)NIL;
  46. X            break ;
  47. X          case nparfunc:
  48. X            tq->U.V15.tparid = newid(currsym.U.V1.vid);
  49. X            nextsymbol(*((symset *)Conset[94]));
  50. X            if (currsym.st == slpar) {
  51. X                enterscope((declptr)NIL);
  52. X                tq->U.V15.tparparm = psubpar();
  53. X                nextsymbol(*((symset *)Conset[95]));
  54. X                leavescope();
  55. X            } else
  56. X                tq->U.V15.tparparm = (struct S61 *)NIL;
  57. X            nextsymbol(*((symset *)Conset[96]));
  58. X            tq->U.V15.tpartyp = oldid(currsym.U.V1.vid, lidentifier);
  59. X            nextsymbol(*((symset *)Conset[97]));
  60. X            break ;
  61. X          default:
  62. X            Caseerror(Line);
  63. X        }
  64. X    } while (!(currsym.st == srpar));
  65. X    R142 = tp;
  66. X    return R142;
  67. X}
  68. X
  69. X treeptr
  70. Xplabstmt()
  71. X{
  72. X    register treeptr    R143;
  73. X    treeptr    tp;
  74. X
  75. X    nextsymbol(*((symset *)Conset[98]));
  76. X    if (currsym.st == sinteger) {
  77. X        tp = mknode(nlabstmt);
  78. X        tp->U.V25.tlabno = oldlbl(true);
  79. X        nextsymbol(*((symset *)Conset[99]));
  80. X        nextsymbol(*((symset *)Conset[100]));
  81. X        tp->U.V25.tstmt = pstmt();
  82. X    } else
  83. X        tp = pstmt();
  84. X    R143 = tp;
  85. X    return R143;
  86. X}
  87. X
  88. X treeptr
  89. Xpstmt()
  90. X{
  91. X    register treeptr    R144;
  92. X    treeptr    tp;
  93. X
  94. X    switch (currsym.st) {
  95. X      case sid:
  96. X        tp = psimple();
  97. X        break ;
  98. X      case sif:
  99. X        tp = pif();
  100. X        break ;
  101. X      case swhile:
  102. X        tp = pwhile();
  103. X        break ;
  104. X      case srepeat:
  105. X        tp = prepeat();
  106. X        break ;
  107. X      case sfor:
  108. X        tp = pfor();
  109. X        break ;
  110. X      case scase:
  111. X        tp = pcase();
  112. X        break ;
  113. X      case swith:
  114. X        tp = pwith();
  115. X        break ;
  116. X      case sbegin:
  117. X        tp = pbegin(true);
  118. X        break ;
  119. X      case sgoto:
  120. X        tp = pgoto();
  121. X        break ;
  122. X      case send:  case selse:  case suntil:  case ssemic:
  123. X        tp = mknode(nempty);
  124. X        break ;
  125. X      default:
  126. X        Caseerror(Line);
  127. X    }
  128. X    R144 = tp;
  129. X    return R144;
  130. X}
  131. X
  132. X treeptr
  133. Xpsimple()
  134. X{
  135. X    register treeptr    R145;
  136. X    treeptr    tq, tp;
  137. X
  138. X    tp = pvariable(oldid(currsym.U.V1.vid, lidentifier));
  139. X    if (currsym.st == sassign) {
  140. X        tq = mknode(nassign);
  141. X        tq->U.V27.tlhs = tp;
  142. X        tq->U.V27.trhs = pexpr((treeptr)NIL);
  143. X        tp = tq;
  144. X    }
  145. X    R145 = tp;
  146. X    return R145;
  147. X}
  148. X
  149. X treeptr
  150. Xpvariable(varptr)
  151. X    treeptr    varptr;
  152. X{
  153. X    register treeptr    R146;
  154. X    treeptr    tp, tq;
  155. X
  156. X    nextsymbol(*((symset *)Conset[101]));
  157. X    if (Member((unsigned)(currsym.st), Conset[102])) {
  158. X        switch (currsym.st) {
  159. X          case slpar:
  160. X            tp = mknode(ncall);
  161. X            tp->U.V30.tcall = varptr;
  162. X            tq = (struct S61 *)NIL;
  163. X            do {
  164. X                if (tq == (struct S61 *)NIL) {
  165. X                    tq = pexpr((treeptr)NIL);
  166. X                    tp->U.V30.taparm = tq;
  167. X                } else {
  168. X                    tq->tnext = pexpr((treeptr)NIL);
  169. X                    tq = tq->tnext;
  170. X                }
  171. X            } while (!(currsym.st == srpar));
  172. X            break ;
  173. X          case slbrack:
  174. X            tq = varptr;
  175. X            do {
  176. X                tp = mknode(nindex);
  177. X                tp->U.V39.tvariable = tq;
  178. X                tp->U.V39.toffset = pexpr((treeptr)NIL);
  179. X                tq = tp;
  180. X            } while (!(currsym.st == srbrack));
  181. X            break ;
  182. X          case sdot:
  183. X            tp = mknode(nselect);
  184. X            tp->U.V40.trecord = varptr;
  185. X            nextsymbol(*((symset *)Conset[103]));
  186. X            tq = typeof(varptr);
  187. X            enterscope(tq->U.V21.trscope);
  188. X            tp->U.V40.tfield = oldid(currsym.U.V1.vid, lfield);
  189. X            leavescope();
  190. X            break ;
  191. X          case sarrow:
  192. X            tp = mknode(nderef);
  193. X            tp->U.V42.texps = varptr;
  194. X            break ;
  195. X          default:
  196. X            Caseerror(Line);
  197. X        }
  198. X        tp = pvariable(tp);
  199. X    } else {
  200. X        tp = varptr;
  201. X        if (tp->tt == nid) {
  202. X            tq = idup(tp);
  203. X            if (tq != (struct S61 *)NIL)
  204. X                if (Member((unsigned)(tq->tt), Conset[104])) {
  205. X                    tp = mknode(ncall);
  206. X                    tp->U.V30.tcall = varptr;
  207. X                    tp->U.V30.taparm = (struct S61 *)NIL;
  208. X                }
  209. X        }
  210. X    }
  211. X    R146 = tp;
  212. X    return R146;
  213. X}
  214. X
  215. Xtreeptr pexpr();
  216. X
  217. X treeptr
  218. Xpadjust(tu, tr)
  219. X    treeptr    tu, tr;
  220. X{
  221. X    register treeptr    R148;
  222. X
  223. X    if (pprio.A[(int)(tu->tt) - (int)(nassign)] >= pprio.A[(int)(tr->tt) - (int)(nassign)]) {
  224. X        if (Member((unsigned)(tr->tt), Conset[105]))
  225. X            tr->U.V42.texps = padjust(tu, tr->U.V42.texps);
  226. X        else
  227. X            tr->U.V41.texpl = padjust(tu, tr->U.V41.texpl);
  228. X        R148 = tr;
  229. X    } else {
  230. X        if (Member((unsigned)(tu->tt), Conset[106]))
  231. X            tu->U.V42.texps = tr;
  232. X        else
  233. X            tu->U.V41.texpr = tr;
  234. X        R148 = tu;
  235. X    }
  236. X    return R148;
  237. X}
  238. X
  239. X treeptr
  240. Xpexpr(tnp)
  241. X    treeptr    tnp;
  242. X{
  243. X    register treeptr    R147;
  244. X    treeptr    tp, tq;
  245. X    treetyp    nt;
  246. X    boolean    next;
  247. X
  248. X    nextsymbol(*((symset *)Conset[107]));
  249. X    next = true;
  250. X    switch (currsym.st) {
  251. X      case splus:
  252. X        tp = mknode(nuplus);
  253. X        tp->U.V42.texps = (struct S61 *)NIL;
  254. X        tp = pexpr(tp);
  255. X        next = false;
  256. X        break ;
  257. X      case sminus:
  258. X        tp = mknode(numinus);
  259. X        tp->U.V42.texps = (struct S61 *)NIL;
  260. X        tp = pexpr(tp);
  261. X        next = false;
  262. X        break ;
  263. X      case snot:
  264. X        tp = mknode(nnot);
  265. X        tp->U.V42.texps = (struct S61 *)NIL;
  266. X        tp = pexpr(tp);
  267. X        next = false;
  268. X        break ;
  269. X      case schar:  case sinteger:  case sreal:  case sstring:
  270. X        tp = mklit();
  271. X        break ;
  272. X      case snil:
  273. X        usenilp = true;
  274. X        tp = mknode(nnil);
  275. X        break ;
  276. X      case sid:
  277. X        tp = pvariable(oldid(currsym.U.V1.vid, lidentifier));
  278. X        next = false;
  279. X        break ;
  280. X      case slpar:
  281. X        tp = mknode(nuplus);
  282. X        tp->U.V42.texps = pexpr((treeptr)NIL);
  283. X        break ;
  284. X      case slbrack:
  285. X        usesets = true;
  286. X        tp = mknode(nset);
  287. X        tp->U.V42.texps = (struct S61 *)NIL;
  288. X        tq = (struct S61 *)NIL;
  289. X        do {
  290. X            if (tq == (struct S61 *)NIL) {
  291. X                tq = pexpr((treeptr)NIL);
  292. X                tp->U.V42.texps = tq;
  293. X            } else {
  294. X                tq->tnext = pexpr((treeptr)NIL);
  295. X                tq = tq->tnext;
  296. X            }
  297. X        } while (!(currsym.st == srbrack));
  298. X        break ;
  299. X      case srbrack:
  300. X        tp = mknode(nempty);
  301. X        next = false;
  302. X        break ;
  303. X      default:
  304. X        Caseerror(Line);
  305. X    }
  306. X    if (next)
  307. X        nextsymbol(*((symset *)Conset[108]));
  308. X    switch (currsym.st) {
  309. X      case sdotdot:
  310. X        nt = nrange;
  311. X        break ;
  312. X      case splus:
  313. X        nt = nplus;
  314. X        break ;
  315. X      case sminus:
  316. X        nt = nminus;
  317. X        break ;
  318. X      case smul:
  319. X        nt = nmul;
  320. X        break ;
  321. X      case sdiv:
  322. X        nt = ndiv;
  323. X        break ;
  324. X      case smod:
  325. X        nt = nmod;
  326. X        break ;
  327. X      case squot:
  328. X        defnams.A[(int)(dreal)]->U.V6.lused = true;
  329. X        nt = nquot;
  330. X        break ;
  331. X      case sand:
  332. X        nt = nand;
  333. X        break ;
  334. X      case sor:
  335. X        nt = nor;
  336. X        break ;
  337. X      case sinn:
  338. X        nt = nin;
  339. X        usesets = true;
  340. X        break ;
  341. X      case sle:
  342. X        nt = nle;
  343. X        break ;
  344. X      case slt:
  345. X        nt = nlt;
  346. X        break ;
  347. X      case seq:
  348. X        nt = neq;
  349. X        break ;
  350. X      case sge:
  351. X        nt = nge;
  352. X        break ;
  353. X      case sgt:
  354. X        nt = ngt;
  355. X        break ;
  356. X      case sne:
  357. X        nt = nne;
  358. X        break ;
  359. X      case scolon:
  360. X        nt = nformat;
  361. X        break ;
  362. X      case sid:  case schar:  case sinteger:  case sreal:
  363. X      case sstring:  case snil:  case ssemic:  case scomma:
  364. X      case slpar:  case slbrack:  case srpar:  case srbrack:
  365. X      case send:  case suntil:  case sthen:  case selse:
  366. X      case sdo:  case sdownto:  case sto:  case sof:
  367. X        nt = nnil;
  368. X        break ;
  369. X      default:
  370. X        Caseerror(Line);
  371. X    }
  372. X    if (Member((unsigned)(nt), Conset[109]))
  373. X        defnams.A[(int)(dboolean)]->U.V6.lused = true;
  374. X    if (nt != nnil) {
  375. X        tq = mknode(nt);
  376. X        tq->U.V41.texpl = tp;
  377. X        tq->U.V41.texpr = (struct S61 *)NIL;
  378. X        tp = pexpr(tq);
  379. X    }
  380. X    if (tnp != (struct S61 *)NIL)
  381. X        tp = padjust(tnp, tp);
  382. X    R147 = tp;
  383. X    return R147;
  384. X}
  385. X
  386. X treeptr
  387. Xpcase()
  388. X{
  389. X    register treeptr    R149;
  390. X    treeptr    tp, tq, tv;
  391. X
  392. X    tp = mknode(ncase);
  393. X    tp->U.V35.tcasxp = pexpr((treeptr)NIL);
  394. X    checksymbol(*((symset *)Conset[110]));
  395. X    tq = (struct S61 *)NIL;
  396. X    do {
  397. X        if (tq == (struct S61 *)NIL) {
  398. X            tq = mknode(nchoise);
  399. X            tp->U.V35.tcaslst = tq;
  400. X        } else {
  401. X            tq->tnext = mknode(nchoise);
  402. X            tq = tq->tnext;
  403. X        }
  404. X        tv = (struct S61 *)NIL;
  405. X        do {
  406. X            nextsymbol(*((symset *)Conset[111]));
  407. X            if (Member((unsigned)(currsym.st), Conset[112]))
  408. X                goto L999;
  409. X            if (tv == (struct S61 *)NIL) {
  410. X                tv = pconstant(false);
  411. X                tq->U.V36.tchocon = tv;
  412. X            } else {
  413. X                tv->tnext = pconstant(false);
  414. X                tv = tv->tnext;
  415. X            }
  416. X            nextsymbol(*((symset *)Conset[113]));
  417. X        } while (!(currsym.st == scolon));
  418. X        tq->U.V36.tchostmt = plabstmt();
  419. X    } while (!(currsym.st == send));
  420. XL999:
  421. X    if (currsym.st == sother) {
  422. X        nextsymbol(*((symset *)Conset[114]));
  423. X        if (currsym.st == scolon)
  424. X            nextsymbol(*((symset *)Conset[115]));
  425. X        tp->U.V35.tcasother = pstmt();
  426. X    } else {
  427. X        tp->U.V35.tcasother = (struct S61 *)NIL;
  428. X        usecase = true;
  429. X    }
  430. X    nextsymbol(*((symset *)Conset[116]));
  431. X    R149 = tp;
  432. X    return R149;
  433. X}
  434. X
  435. X treeptr
  436. Xpif()
  437. X{
  438. X    register treeptr    R150;
  439. X    treeptr    tp;
  440. X
  441. X    tp = mknode(nif);
  442. X    tp->U.V31.tifxp = pexpr((treeptr)NIL);
  443. X    checksymbol(*((symset *)Conset[117]));
  444. X    tp->U.V31.tthen = plabstmt();
  445. X    if (currsym.st == selse)
  446. X        tp->U.V31.telse = plabstmt();
  447. X    else
  448. X        tp->U.V31.telse = (struct S61 *)NIL;
  449. X    R150 = tp;
  450. X    return R150;
  451. X}
  452. X
  453. X treeptr
  454. Xpwhile()
  455. X{
  456. X    register treeptr    R151;
  457. X    treeptr    tp;
  458. X
  459. X    tp = mknode(nwhile);
  460. X    tp->U.V32.twhixp = pexpr((treeptr)NIL);
  461. X    checksymbol(*((symset *)Conset[118]));
  462. X    tp->U.V32.twhistmt = plabstmt();
  463. X    R151 = tp;
  464. X    return R151;
  465. X}
  466. X
  467. X treeptr
  468. Xprepeat()
  469. X{
  470. X    register treeptr    R152;
  471. X    treeptr    tp, tq;
  472. X
  473. X    tp = mknode(nrepeat);
  474. X    tq = (struct S61 *)NIL;
  475. X    do {
  476. X        if (tq == (struct S61 *)NIL) {
  477. X            tq = plabstmt();
  478. X            tp->U.V33.treptstmt = tq;
  479. X        } else {
  480. X            tq->tnext = plabstmt();
  481. X            tq = tq->tnext;
  482. X        }
  483. X        checksymbol(*((symset *)Conset[119]));
  484. X    } while (!(currsym.st == suntil));
  485. X    tp->U.V33.treptxp = pexpr((treeptr)NIL);
  486. X    R152 = tp;
  487. X    return R152;
  488. X}
  489. X
  490. X treeptr
  491. Xpfor()
  492. X{
  493. X    register treeptr    R153;
  494. X    treeptr    tp;
  495. X
  496. X    tp = mknode(nfor);
  497. X    nextsymbol(*((symset *)Conset[120]));
  498. X    tp->U.V34.tforid = oldid(currsym.U.V1.vid, lidentifier);
  499. X    nextsymbol(*((symset *)Conset[121]));
  500. X    tp->U.V34.tfrom = pexpr((treeptr)NIL);
  501. X    checksymbol(*((symset *)Conset[122]));
  502. X    tp->U.V34.tincr = (boolean)(currsym.st == sto);
  503. X    tp->U.V34.tto = pexpr((treeptr)NIL);
  504. X    checksymbol(*((symset *)Conset[123]));
  505. X    tp->U.V34.tforstmt = plabstmt();
  506. X    R153 = tp;
  507. X    return R153;
  508. X}
  509. X
  510. X treeptr
  511. Xpwith()
  512. X{
  513. X    register treeptr    R154;
  514. X    treeptr    tp, tq;
  515. X
  516. X    tp = mknode(nwith);
  517. X    tq = (struct S61 *)NIL;
  518. X    do {
  519. X        if (tq == (struct S61 *)NIL) {
  520. X            tq = mknode(nwithvar);
  521. X            tp->U.V37.twithvar = tq;
  522. X        } else {
  523. X            tq->tnext = mknode(nwithvar);
  524. X            tq = tq->tnext;
  525. X        }
  526. X        enterscope((declptr)NIL);
  527. X        tq->U.V38.tenv = currscope();
  528. X        tq->U.V38.texpw = pexpr((treeptr)NIL);
  529. X        scopeup(tq->U.V38.texpw);
  530. X        checksymbol(*((symset *)Conset[124]));
  531. X    } while (!(currsym.st == sdo));
  532. X    tp->U.V37.twithstmt = plabstmt();
  533. X    tq = tp->U.V37.twithvar;
  534. X    while (tq != (struct S61 *)NIL) {
  535. X        leavescope();
  536. X        tq = tq->tnext;
  537. X    }
  538. X    R154 = tp;
  539. X    return R154;
  540. X}
  541. X
  542. X treeptr
  543. Xpgoto()
  544. X{
  545. X    register treeptr    R155;
  546. X    treeptr    tp;
  547. X
  548. X    nextsymbol(*((symset *)Conset[125]));
  549. X    tp = mknode(ngoto);
  550. X    tp->U.V26.tlabel = oldlbl(false);
  551. X    nextsymbol(*((symset *)Conset[126]));
  552. X    R155 = tp;
  553. X    return R155;
  554. X}
  555. X
  556. X treeptr
  557. Xpbegin(retain)
  558. X    boolean    retain;
  559. X{
  560. X    register treeptr    R156;
  561. X    treeptr    tp, tq;
  562. X
  563. X    tq = (struct S61 *)NIL;
  564. X    do {
  565. X        if (tq == (struct S61 *)NIL) {
  566. X            tq = plabstmt();
  567. X            tp = tq;
  568. X        } else {
  569. X            tq->tnext = plabstmt();
  570. X            tq = tq->tnext;
  571. X        }
  572. X    } while (!(currsym.st == send));
  573. X    if (retain) {
  574. X        tq = mknode(nbegin);
  575. X        tq->U.V24.tbegin = tp;
  576. X        tp = tq;
  577. X    }
  578. X    nextsymbol(*((symset *)Conset[127]));
  579. X    R156 = tp;
  580. X    return R156;
  581. X}
  582. X
  583. X void
  584. Xparse()
  585. X{
  586. X    nextsymbol(*((symset *)Conset[128]));
  587. X    if (currsym.st == spgm)
  588. X        top = pprogram();
  589. X    else
  590. X        top = pmodule();
  591. X    nextsymbol(*((symset *)Conset[129]));
  592. X}
  593. X
  594. X integer
  595. Xcvalof(tp)
  596. X    treeptr    tp;
  597. X{
  598. X    register integer    R157;
  599. X    integer    v;
  600. X    treeptr    tq;
  601. X
  602. X    switch (tp->tt) {
  603. X      case nuplus:
  604. X        R157 = cvalof(tp->U.V42.texps);
  605. X        break ;
  606. X      case numinus:
  607. X        R157 = -cvalof(tp->U.V42.texps);
  608. X        break ;
  609. X      case nnot:
  610. X        R157 = 1 - cvalof(tp->U.V42.texps);
  611. X        break ;
  612. X      case nid:
  613. X        tq = idup(tp);
  614. X        if (tq == (struct S61 *)NIL)
  615. X            fatal(etree);
  616. X        tp = tp->U.V43.tsym->lsymdecl;
  617. X        switch (tq->tt) {
  618. X          case nscalar:
  619. X            v = 0;
  620. X            tq = tq->U.V17.tscalid;
  621. X            while (tq != (struct S61 *)NIL)
  622. X                if (tq == tp)
  623. X                    tq = (struct S61 *)NIL;
  624. X                else {
  625. X                    v = v + 1;
  626. X                    tq = tq->tnext;
  627. X                }
  628. X            R157 = v;
  629. X            break ;
  630. X          case nconst:
  631. X            R157 = cvalof(tq->U.V14.tbind);
  632. X            break ;
  633. X          default:
  634. X            Caseerror(Line);
  635. X        }
  636. X        break ;
  637. X      case ninteger:
  638. X        R157 = tp->U.V43.tsym->U.V10.linum;
  639. X        break ;
  640. X      case nchar:
  641. X        R157 = (unsigned)(tp->U.V43.tsym->U.V11.lchar);
  642. X        break ;
  643. X      default:
  644. X        Caseerror(Line);
  645. X    }
  646. X    return R157;
  647. X}
  648. X
  649. X integer
  650. Xclower(tp)
  651. X    treeptr    tp;
  652. X{
  653. X    register integer    R158;
  654. X    treeptr    tq;
  655. X
  656. X    tq = typeof(tp);
  657. X    if (tq->tt == nscalar)
  658. X        R158 = scalbase;
  659. X    else
  660. X        if (tq->tt == nsubrange)
  661. X            if (tq->tup->tt == nconfarr)
  662. X                R158 = 0;
  663. X            else
  664. X                R158 = cvalof(tq->U.V19.tlo);
  665. X        else
  666. X            if (tq == typnods.A[(int)(tchar)])
  667. X                R158 = 0;
  668. X            else
  669. X                if (tq == typnods.A[(int)(tinteger)])
  670. X                    R158 = -maxint;
  671. X                else
  672. X                    fatal(etree);
  673. X    return R158;
  674. X}
  675. X
  676. X integer
  677. Xcupper(tp)
  678. X    treeptr    tp;
  679. X{
  680. X    register integer    R159;
  681. X    treeptr    tq;
  682. X    integer    i;
  683. X
  684. X    tq = typeof(tp);
  685. X    if (tq->tt == nscalar) {
  686. X        tq = tq->U.V17.tscalid;
  687. X        i = scalbase;
  688. X        while (tq->tnext != (struct S61 *)NIL) {
  689. X            i = i + 1;
  690. X            tq = tq->tnext;
  691. X        }
  692. X        R159 = i;
  693. X    } else
  694. X        if (tq->tt == nsubrange)
  695. X            if (tq->tup->tt == nconfarr)
  696. X                fatal(euprconf);
  697. X            else
  698. X                R159 = cvalof(tq->U.V19.thi);
  699. X        else
  700. X            if (tq == typnods.A[(int)(tchar)])
  701. X                R159 = maxchar;
  702. X            else
  703. X                if (tq == typnods.A[(int)(tinteger)])
  704. X                    R159 = maxint;
  705. X                else
  706. X                    fatal(etree);
  707. X    return R159;
  708. X}
  709. X
  710. X integer
  711. Xcrange(tp)
  712. X    treeptr    tp;
  713. X{
  714. X    register integer    R160;
  715. X
  716. X    R160 = cupper(tp) - clower(tp) + 1;
  717. X    return R160;
  718. X}
  719. X
  720. X integer
  721. Xcsetwords(i)
  722. X    integer    i;
  723. X{
  724. X    register integer    R161;
  725. X
  726. X    i = (i + (C37_setbits)) / (C37_setbits + 1);
  727. X    if (i > maxsetrange)
  728. X        error(esetsize);
  729. X    R161 = i;
  730. X    return R161;
  731. X}
  732. X
  733. X integer
  734. Xcsetsize(tp)
  735. X    treeptr    tp;
  736. X{
  737. X    register integer    R162;
  738. X    treeptr    tq;
  739. X    integer    i;
  740. X
  741. X    tq = typeof(tp->U.V18.tof);
  742. X    i = clower(tq);
  743. X    if ((i < 0) || (i >= 6 * (C37_setbits + 1)))
  744. X        error(esetbase);
  745. X    R162 = csetwords(crange(tq)) + 1;
  746. X    return R162;
  747. X}
  748. X
  749. X boolean
  750. Xislocal(tp)
  751. X    treeptr    tp;
  752. X{
  753. X    register boolean    R163;
  754. X    treeptr    tq;
  755. X
  756. X    tq = tp->U.V43.tsym->lsymdecl;
  757. X    while (!(Member((unsigned)(tq->tt), Conset[130])))
  758. X        tq = tq->tup;
  759. X    while (!(Member((unsigned)(tp->tt), Conset[131])))
  760. X        tp = tp->tup;
  761. X    R163 = (boolean)(tp == tq);
  762. X    return R163;
  763. X}
  764. X
  765. Xvoid transform();
  766. X
  767. Xvoid renamf();
  768. X
  769. X void
  770. Xcrtnvar(tp)
  771. X    treeptr    tp;
  772. X{
  773. X    while (tp != (struct S61 *)NIL) {
  774. X        switch (tp->tt) {
  775. X          case npgm:
  776. X            crtnvar(tp->U.V13.tsubsub);
  777. X            break ;
  778. X          case nfunc:  case nproc:
  779. X            crtnvar(tp->U.V13.tsubsub);
  780. X            crtnvar(tp->U.V13.tsubstmt);
  781. X            break ;
  782. X          case nbegin:
  783. X            crtnvar(tp->U.V24.tbegin);
  784. X            break ;
  785. X          case nif:
  786. X            crtnvar(tp->U.V31.tthen);
  787. X            crtnvar(tp->U.V31.telse);
  788. X            break ;
  789. X          case nwhile:
  790. X            crtnvar(tp->U.V32.twhistmt);
  791. X            break ;
  792. X          case nrepeat:
  793. X            crtnvar(tp->U.V33.treptstmt);
  794. X            break ;
  795. X          case nfor:
  796. X            crtnvar(tp->U.V34.tforstmt);
  797. X            break ;
  798. X          case ncase:
  799. X            crtnvar(tp->U.V35.tcaslst);
  800. X            crtnvar(tp->U.V35.tcasother);
  801. X            break ;
  802. X          case nchoise:
  803. X            crtnvar(tp->U.V36.tchostmt);
  804. X            break ;
  805. X          case nwith:
  806. X            crtnvar(tp->U.V37.twithstmt);
  807. X            break ;
  808. X          case nlabstmt:
  809. X            crtnvar(tp->U.V25.tstmt);
  810. X            break ;
  811. X          case nassign:
  812. X            if (tp->U.V27.tlhs->tt == ncall) {
  813. X                tp->U.V27.tlhs = tp->U.V27.tlhs->U.V30.tcall;
  814. X                tp->U.V27.tlhs->tup = tp;
  815. X            }
  816. X            (*G187_tv) = tp->U.V27.tlhs;
  817. X            if ((*G187_tv)->tt == nid)
  818. X                if ((*G187_tv)->U.V43.tsym == (*G183_ip))
  819. X                    (*G187_tv)->U.V43.tsym = (*G185_iq);
  820. X            break ;
  821. X          case nbreak:  case npush:  case npop:  case ngoto:
  822. X          case nempty:  case ncall:
  823. X            break ;
  824. X          default:
  825. X            Caseerror(Line);
  826. X        }
  827. X        tp = tp->tnext;
  828. X    }
  829. X}
  830. X
  831. X void
  832. Xrenamf(tp)
  833. X    treeptr    tp;
  834. X{
  835. X    symptr    ip, iq;
  836. X    treeptr    tq, tv;
  837. X    symptr    *F184;
  838. X    symptr    *F186;
  839. X    treeptr    *F188;
  840. X
  841. X    F188 = G187_tv;
  842. X    G187_tv = &tv;
  843. X    F186 = G185_iq;
  844. X    G185_iq = &iq;
  845. X    F184 = G183_ip;
  846. X    G183_ip = &ip;
  847. X    while (tp != (struct S61 *)NIL) {
  848. X        switch (tp->tt) {
  849. X          case npgm:  case nproc:
  850. X            renamf(tp->U.V13.tsubsub);
  851. X            break ;
  852. X          case nfunc:
  853. X            tq = mknode(nvar);
  854. X            tq->U.V14.tattr = aregister;
  855. X            tq->tup = tp;
  856. X            tq->U.V14.tidl = newid(mkvariable('R'));
  857. X            tq->U.V14.tidl->tup = tq;
  858. X            tq->U.V14.tbind = tp->U.V13.tfuntyp;
  859. X            tq->tnext = tp->U.V13.tsubvar;
  860. X            tp->U.V13.tsubvar = tq;
  861. X            (*G185_iq) = tq->U.V14.tidl->U.V43.tsym;
  862. X            (*G183_ip) = tp->U.V13.tsubid->U.V43.tsym;
  863. X            crtnvar(tp->U.V13.tsubsub);
  864. X            crtnvar(tp->U.V13.tsubstmt);
  865. X            renamf(tp->U.V13.tsubsub);
  866. X            break ;
  867. X          default:
  868. X            Caseerror(Line);
  869. X        }
  870. X        tp = tp->tnext;
  871. X    }
  872. X    G183_ip = F184;
  873. X    G185_iq = F186;
  874. X    G187_tv = F188;
  875. X}
  876. X
  877. Xvoid extract();
  878. X
  879. X treeptr
  880. Xxtrit(tp, pp, last)
  881. X    treeptr    tp, pp;
  882. X    boolean    last;
  883. X{
  884. X    register treeptr    R164;
  885. X    treeptr    np, rp;
  886. X    idptr    ip;
  887. X
  888. X    np = mknode(ntype);
  889. X    ip = mkvariable('T');
  890. X    np->U.V14.tidl = newid(ip);
  891. X    np->U.V14.tidl->tup = np;
  892. X    rp = oldid(ip, lidentifier);
  893. X    rp->tup = tp->tup;
  894. X    rp->tnext = tp->tnext;
  895. X    np->U.V14.tbind = tp;
  896. X    tp->tup = np;
  897. X    tp->tnext = (struct S61 *)NIL;
  898. X    np->tup = pp;
  899. X    if (last && (pp->U.V13.tsubtype != (struct S61 *)NIL)) {
  900. X        pp = pp->U.V13.tsubtype;
  901. X        while (pp->tnext != (struct S61 *)NIL)
  902. X            pp = pp->tnext;
  903. X        pp->tnext = np;
  904. X    } else {
  905. X        np->tnext = pp->U.V13.tsubtype;
  906. X        pp->U.V13.tsubtype = np;
  907. X    }
  908. X    R164 = rp;
  909. X    return R164;
  910. X}
  911. X
  912. Xtreeptr xtrenum();
  913. X
  914. X void
  915. Xnametype(tp)
  916. X    treeptr    tp;
  917. X{
  918. X    tp = typeof(tp);
  919. X    if (tp->tt == nrecord)
  920. X        if (tp->U.V21.tuid == (struct S59 *)NIL)
  921. X            tp->U.V21.tuid = mkvariable('S');
  922. X}
  923. X
  924. X treeptr
  925. Xxtrenum(tp, pp)
  926. X    treeptr    tp, pp;
  927. X{
  928. X    register treeptr    R165;
  929. X
  930. X    if (tp != (struct S61 *)NIL) {
  931. X        switch (tp->tt) {
  932. X          case nfield:  case ntype:  case nvar:
  933. X            tp->U.V14.tbind = xtrenum(tp->U.V14.tbind, pp);
  934. X            break ;
  935. X          case nscalar:
  936. X            if (tp->tup->tt != ntype)
  937. X                tp = xtrit(tp, pp, false);
  938. X            break ;
  939. X          case narray:
  940. X            tp->U.V23.taindx = xtrenum(tp->U.V23.taindx, pp);
  941. X            tp->U.V23.taelem = xtrenum(tp->U.V23.taelem, pp);
  942. X            break ;
  943. X          case nrecord:
  944. X            tp->U.V21.tflist = xtrenum(tp->U.V21.tflist, pp);
  945. X            tp->U.V21.tvlist = xtrenum(tp->U.V21.tvlist, pp);
  946. X            break ;
  947. X          case nvariant:
  948. X            tp->U.V20.tvrnt = xtrenum(tp->U.V20.tvrnt, pp);
  949. X            break ;
  950. X          case nfileof:
  951. X            tp->U.V18.tof = xtrenum(tp->U.V18.tof, pp);
  952. X            break ;
  953. X          case nptr:
  954. X            nametype(tp->U.V16.tptrid);
  955. X            break ;
  956. X          case nid:  case nsubrange:  case npredef:  case nempty:
  957. X          case nsetof:
  958. X            break ;
  959. X          default:
  960. X            Caseerror(Line);
  961. X        }
  962. X        tp->tnext = xtrenum(tp->tnext, pp);
  963. X    }
  964. X    R165 = tp;
  965. X    return R165;
  966. X}
  967. X
  968. X void
  969. Xextract(tp)
  970. X    treeptr    tp;
  971. X{
  972. X    treeptr    vp;
  973. X
  974. X    while (tp != (struct S61 *)NIL) {
  975. X        tp->U.V13.tsubtype = xtrenum(tp->U.V13.tsubtype, tp);
  976. X        tp->U.V13.tsubvar = xtrenum(tp->U.V13.tsubvar, tp);
  977. X        vp = tp->U.V13.tsubvar;
  978. X        while (vp != (struct S61 *)NIL) {
  979. X            if (Member((unsigned)(vp->U.V14.tbind->tt), Conset[132]))
  980. X                vp->U.V14.tbind = xtrit(vp->U.V14.tbind, tp, true);
  981. X            vp = vp->tnext;
  982. X        }
  983. X        extract(tp->U.V13.tsubsub);
  984. X        tp = tp->tnext;
  985. X    }
  986. X}
  987. X
  988. Xvoid global();
  989. X
  990. X void
  991. Xmarkdecl(xp)
  992. X    treeptr    xp;
  993. X{
  994. X    while (xp != (struct S61 *)NIL) {
  995. X        switch (xp->tt) {
  996. X          case nid:
  997. X            xp->U.V43.tsym->U.V6.lused = false;
  998. X            break ;
  999. X          case nconst:
  1000. X            markdecl(xp->U.V14.tidl);
  1001. X            break ;
  1002. X          case ntype:  case nvar:  case nvalpar:  case nvarpar:
  1003. X          case nfield:
  1004. X            markdecl(xp->U.V14.tidl);
  1005. X            if (xp->U.V14.tbind->tt != nid)
  1006. X                markdecl(xp->U.V14.tbind);
  1007. X            break ;
  1008. X          case nscalar:
  1009. X            markdecl(xp->U.V17.tscalid);
  1010. X            break ;
  1011. X          case nrecord:
  1012. X            markdecl(xp->U.V21.tflist);
  1013. X            markdecl(xp->U.V21.tvlist);
  1014. X            break ;
  1015. X          case nvariant:
  1016. X            markdecl(xp->U.V20.tvrnt);
  1017. X            break ;
  1018. X          case nconfarr:
  1019. X            if (xp->U.V22.tcelem->tt != nid)
  1020. X                markdecl(xp->U.V22.tcelem);
  1021. X            break ;
  1022. X          case narray:
  1023. X            if (xp->U.V23.taelem->tt != nid)
  1024. X                markdecl(xp->U.V23.taelem);
  1025. X            break ;
  1026. X          case nsetof:  case nfileof:
  1027. X            if (xp->U.V18.tof->tt != nid)
  1028. X                markdecl(xp->U.V18.tof);
  1029. X            break ;
  1030. X          case nparproc:  case nparfunc:
  1031. X            markdecl(xp->U.V15.tparid);
  1032. X            break ;
  1033. X          case nptr:  case nsubrange:
  1034. X            break ;
  1035. X          default:
  1036. X            Caseerror(Line);
  1037. X        }
  1038. X        xp = xp->tnext;
  1039. X    }
  1040. X}
  1041. X
  1042. X treeptr
  1043. Xmovedecl(tp)
  1044. X    treeptr    tp;
  1045. X{
  1046. X    register treeptr    R166;
  1047. X    treeptr    ip, np;
  1048. X    symptr    sp;
  1049. X    boolean    move;
  1050. X
  1051. X    if (tp != (struct S61 *)NIL) {
  1052. X        move = false;
  1053. X        switch (tp->tt) {
  1054. X          case nconst:  case ntype:
  1055. X            ip = tp->U.V14.tidl;
  1056. X            break ;
  1057. X          default:
  1058. X            Caseerror(Line);
  1059. X        }
  1060. X        while (ip != (struct S61 *)NIL) {
  1061. X            if (ip->U.V43.tsym->U.V6.lused) {
  1062. X                move = true;
  1063. X                sp = ip->U.V43.tsym;
  1064. X                if (sp->U.V6.lid->inref > 1) {
  1065. X                    sp->U.V6.lid = mkrename('M', sp->U.V6.lid);
  1066. X                    sp->U.V6.lid->inref = sp->U.V6.lid->inref - 1;
  1067. X                }
  1068. X                ip = (struct S61 *)NIL;
  1069. X            } else
  1070. X                ip = ip->tnext;
  1071. X        }
  1072. X        if (move) {
  1073. X            np = tp->tnext;
  1074. X            tp->tnext = (struct S61 *)NIL;
  1075. X            ip = tp;
  1076. X            while (ip->tt != npgm)
  1077. X                ip = ip->tup;
  1078. X            tp->tup = ip;
  1079. X            switch (tp->tt) {
  1080. X              case nconst:
  1081. X                if (ip->U.V13.tsubconst == (struct S61 *)NIL)
  1082. X                    ip->U.V13.tsubconst = tp;
  1083. X                else {
  1084. X                    ip = ip->U.V13.tsubconst;
  1085. X                    while (ip->tnext != (struct S61 *)NIL)
  1086. X                        ip = ip->tnext;
  1087. X                    ip->tnext = tp;
  1088. X                }
  1089. X                break ;
  1090. X              case ntype:
  1091. X                if (ip->U.V13.tsubtype == (struct S61 *)NIL)
  1092. X                    ip->U.V13.tsubtype = tp;
  1093. X                else {
  1094. X                    ip = ip->U.V13.tsubtype;
  1095. X                    while (ip->tnext != (struct S61 *)NIL)
  1096. X                        ip = ip->tnext;
  1097. X                    ip->tnext = tp;
  1098. X                }
  1099. X                break ;
  1100. X              default:
  1101. X                Caseerror(Line);
  1102. X            }
  1103. X            tp = movedecl(np);
  1104. X        } else
  1105. X            tp->tnext = movedecl(tp->tnext);
  1106. X    }
  1107. X    R166 = tp;
  1108. X    return R166;
  1109. X}
  1110. X
  1111. Xvoid movevars();
  1112. X
  1113. X void
  1114. Xmoveglob(tp, dp)
  1115. X    treeptr    tp, dp;
  1116. X{
  1117. X    while (tp->tt != npgm)
  1118. X        tp = tp->tup;
  1119. X    dp->tup = tp;
  1120. X    dp->tnext = tp->U.V13.tsubvar;
  1121. X    tp->U.V13.tsubvar = dp;
  1122. X}
  1123. X
  1124. X treeptr
  1125. Xstackop(decl, glob, loc)
  1126. X    treeptr    decl, glob, loc;
  1127. X{
  1128. X    register treeptr    R167;
  1129. X    treeptr    op, ip, dp, tp;
  1130. X
  1131. X    ip = newid(mkvariable('F'));
  1132. X    switch ((*G189_vp)->tt) {
  1133. X      case nvarpar:  case nvalpar:  case nvar:
  1134. X        dp = mknode(nvarpar);
  1135. X        dp->U.V14.tattr = areference;
  1136. X        dp->U.V14.tidl = ip;
  1137. X        dp->U.V14.tbind = decl->U.V14.tbind;
  1138. X        break ;
  1139. X      case nparproc:  case nparfunc:
  1140. X        dp = mknode((*G189_vp)->tt);
  1141. X        dp->U.V15.tparid = ip;
  1142. X        dp->U.V15.tparparm = (struct S61 *)NIL;
  1143. X        dp->U.V15.tpartyp = (*G189_vp)->U.V15.tpartyp;
  1144. X        break ;
  1145. X      default:
  1146. X        Caseerror(Line);
  1147. X    }
  1148. X    ip->tup = dp;
  1149. X    tp = decl;
  1150. X    while (!(Member((unsigned)(tp->tt), Conset[133])))
  1151. X        tp = tp->tup;
  1152. X    dp->tup = tp;
  1153. X    if (tp->U.V13.tsubvar == (struct S61 *)NIL)
  1154. X        tp->U.V13.tsubvar = dp;
  1155. X    else {
  1156. X        tp = tp->U.V13.tsubvar;
  1157. X        while (tp->tnext != (struct S61 *)NIL)
  1158. X            tp = tp->tnext;
  1159. X        tp->tnext = dp;
  1160. X    }
  1161. X    dp->tnext = (struct S61 *)NIL;
  1162. X    op = mknode(npush);
  1163. X    op->U.V28.tglob = glob;
  1164. X    op->U.V28.tloc = loc;
  1165. X    op->U.V28.ttmp = ip;
  1166. X    R167 = op;
  1167. X    return R167;
  1168. X}
  1169. X
  1170. X void
  1171. Xaddcode(tp, push)
  1172. X    treeptr    tp, push;
  1173. X{
  1174. X    treeptr    pop;
  1175. X
  1176. X    pop = mknode(npop);
  1177. X    pop->U.V28.tglob = push->U.V28.tglob;
  1178. X    pop->U.V28.ttmp = push->U.V28.ttmp;
  1179. X    pop->U.V28.tloc = (struct S61 *)NIL;
  1180. X    push->tnext = tp->U.V13.tsubstmt;
  1181. X    tp->U.V13.tsubstmt = push;
  1182. X    push->tup = tp;
  1183. X    while (push->tnext != (struct S61 *)NIL)
  1184. X        push = push->tnext;
  1185. X    push->tnext = pop;
  1186. X    pop->tup = tp;
  1187. X}
  1188. X
  1189. X void
  1190. Xmovevars(tp, vp)
  1191. X    treeptr    tp, vp;
  1192. X{
  1193. X    treeptr    ep, dp, np;
  1194. X    idptr    ip;
  1195. X    symptr    sp;
  1196. X    treeptr    *F190;
  1197. X
  1198. X    F190 = G189_vp;
  1199. X    G189_vp = &vp;
  1200. X    while ((*G189_vp) != (struct S61 *)NIL) {
  1201. X        switch ((*G189_vp)->tt) {
  1202. X          case nvar:  case nvalpar:  case nvarpar:
  1203. X            dp = (*G189_vp)->U.V14.tidl;
  1204. X            break ;
  1205. X          case nparproc:  case nparfunc:
  1206. X            dp = (*G189_vp)->U.V15.tparid;
  1207. X            if (dp->U.V43.tsym->U.V6.lused) {
  1208. X                ep = mknode((*G189_vp)->tt);
  1209. X                ep->U.V15.tparparm = (struct S61 *)NIL;
  1210. X                ep->U.V15.tpartyp = (*G189_vp)->U.V15.tpartyp;
  1211. X                np = newid(mkrename('G', dp->U.V43.tsym->U.V6.lid));
  1212. X                ep->U.V15.tparid = np;
  1213. X                np->tup = ep;
  1214. X                sp = np->U.V43.tsym;
  1215. X                ip = sp->U.V6.lid;
  1216. X                np->U.V43.tsym->U.V6.lid = dp->U.V43.tsym->U.V6.lid;
  1217. X                dp->U.V43.tsym->U.V6.lid = ip;
  1218. X                np->U.V43.tsym = dp->U.V43.tsym;
  1219. X                dp->U.V43.tsym = sp;
  1220. X                np->U.V43.tsym->lsymdecl = np;
  1221. X                dp->U.V43.tsym->lsymdecl = dp;
  1222. X                moveglob(tp, ep);
  1223. X                addcode(tp, stackop((*G189_vp), np, dp));
  1224. X            }
  1225. X            goto L555;
  1226. X            break ;
  1227. X          default:
  1228. X            Caseerror(Line);
  1229. X        }
  1230. X        while (dp != (struct S61 *)NIL) {
  1231. X            if (dp->U.V43.tsym->U.V6.lused) {
  1232. X                ep = mknode(nvarpar);
  1233. X                ep->U.V14.tattr = areference;
  1234. X                np = newid(mkrename('G', dp->U.V43.tsym->U.V6.lid));
  1235. X                ep->U.V14.tidl = np;
  1236. X                np->tup = ep;
  1237. X                ep->U.V14.tbind = (*G189_vp)->U.V14.tbind;
  1238. X                if (ep->U.V14.tbind->tt == nid)
  1239. X                    ep->U.V14.tbind->U.V43.tsym->U.V6.lused = true;
  1240. X                sp = np->U.V43.tsym;
  1241. X                ip = sp->U.V6.lid;
  1242. X                np->U.V43.tsym->U.V6.lid = dp->U.V43.tsym->U.V6.lid;
  1243. X                dp->U.V43.tsym->U.V6.lid = ip;
  1244. X                np->U.V43.tsym = dp->U.V43.tsym;
  1245. X                dp->U.V43.tsym = sp;
  1246. X                np->U.V43.tsym->lsymdecl = np;
  1247. X                dp->U.V43.tsym->lsymdecl = dp;
  1248. X                dp->tup->U.V14.tattr = aextern;
  1249. X                moveglob(tp, ep);
  1250. X                addcode(tp, stackop((*G189_vp), np, dp));
  1251. X            }
  1252. X            dp = dp->tnext;
  1253. X        }
  1254. X    L555:
  1255. X        (*G189_vp) = (*G189_vp)->tnext;
  1256. X    }
  1257. X    G189_vp = F190;
  1258. X}
  1259. X
  1260. X void
  1261. Xregistervar(tp)
  1262. X    treeptr    tp;
  1263. X{
  1264. X    treeptr    vp, xp;
  1265. X
  1266. X    vp = idup(tp);
  1267. X    tp = tp->U.V43.tsym->lsymdecl;
  1268. X    if ((vp->U.V14.tidl != tp) || (tp->tnext != (struct S61 *)NIL)) {
  1269. X        xp = mknode(nvar);
  1270. X        xp->U.V14.tattr = anone;
  1271. X        xp->U.V14.tidl = tp;
  1272. X        tp->tup = xp;
  1273. X        xp->tup = vp->tup;
  1274. X        xp->U.V14.tbind = vp->U.V14.tbind;
  1275. X        xp->tnext = vp->tnext;
  1276. X        vp->tnext = xp;
  1277. X        if (vp->U.V14.tidl == tp)
  1278. X            vp->U.V14.tidl = tp->tnext;
  1279. X        else {
  1280. X            vp = vp->U.V14.tidl;
  1281. X            while (vp->tnext != tp)
  1282. X                vp = vp->tnext;
  1283. X            vp->tnext = tp->tnext;
  1284. X        }
  1285. X        tp->tnext = (struct S61 *)NIL;
  1286. X    }
  1287. X    if (tp->tup->U.V14.tattr == anone)
  1288. X        tp->tup->U.V14.tattr = aregister;
  1289. X}
  1290. X
  1291. X void
  1292. Xcklevel(tp)
  1293. X    treeptr    tp;
  1294. X{
  1295. X    tp = tp->U.V43.tsym->lsymdecl;
  1296. X    while (!(Member((unsigned)(tp->tt), Conset[134])))
  1297. X        tp = tp->tup;
  1298. X    if (tp->U.V13.tstat > maxlevel)
  1299. X        maxlevel = tp->U.V13.tstat;
  1300. X}
  1301. X
  1302. X void
  1303. Xglobal(tp, dp, depend)
  1304. X    treeptr    tp, dp;
  1305. X    boolean    depend;
  1306. X{
  1307. X    treeptr    ip;
  1308. X    boolean    dep;
  1309. X
  1310. X    while (tp != (struct S61 *)NIL) {
  1311. X        switch (tp->tt) {
  1312. X          case nproc:  case nfunc:
  1313. X            markdecl(tp->U.V13.tsubid);
  1314. X            markdecl(tp->U.V13.tsubpar);
  1315. X            markdecl(tp->U.V13.tsubconst);
  1316. X            markdecl(tp->U.V13.tsubtype);
  1317. X            markdecl(tp->U.V13.tsubvar);
  1318. X            global(tp->U.V13.tsubsub, tp, false);
  1319. X            movevars(tp, tp->U.V13.tsubpar);
  1320. X            movevars(tp, tp->U.V13.tsubvar);
  1321. X            tp->U.V13.tsubtype = movedecl(tp->U.V13.tsubtype);
  1322. X            tp->U.V13.tsubconst = movedecl(tp->U.V13.tsubconst);
  1323. X            global(tp->U.V13.tsubstmt, tp, true);
  1324. X            global(tp->U.V13.tsubpar, tp, false);
  1325. X            global(tp->U.V13.tsubvar, tp, false);
  1326. X            global(tp->U.V13.tsubtype, tp, false);
  1327. X            global(tp->U.V13.tfuntyp, tp, false);
  1328. X            break ;
  1329. X          case npgm:
  1330. X            markdecl(tp->U.V13.tsubconst);
  1331. X            markdecl(tp->U.V13.tsubtype);
  1332. X            markdecl(tp->U.V13.tsubvar);
  1333. X            global(tp->U.V13.tsubsub, tp, false);
  1334. X            global(tp->U.V13.tsubstmt, tp, true);
  1335. X            break ;
  1336. X          case nconst:  case ntype:  case nvar:  case nfield:
  1337. X          case nvalpar:  case nvarpar:
  1338. X            ip = tp->U.V14.tidl;
  1339. X            dep = depend;
  1340. X            while ((ip != (struct S61 *)NIL) && !dep) {
  1341. X                if (ip->U.V43.tsym->U.V6.lused)
  1342. X                    dep = true;
  1343. X                ip = ip->tnext;
  1344. X            }
  1345. X            global(tp->U.V14.tbind, dp, dep);
  1346. X            break ;
  1347. X          case nparproc:  case nparfunc:
  1348. X            global(tp->U.V15.tparparm, dp, depend);
  1349. X            global(tp->U.V15.tpartyp, dp, depend);
  1350. X            break ;
  1351. X          case nsubrange:
  1352. X            global(tp->U.V19.tlo, dp, depend);
  1353. X            global(tp->U.V19.thi, dp, depend);
  1354. X            break ;
  1355. X          case nvariant:
  1356. X            global(tp->U.V20.tselct, dp, depend);
  1357. X            global(tp->U.V20.tvrnt, dp, depend);
  1358. X            break ;
  1359. X          case nrecord:
  1360. X            global(tp->U.V21.tflist, dp, depend);
  1361. X            global(tp->U.V21.tvlist, dp, depend);
  1362. X            break ;
  1363. X          case nconfarr:
  1364. X            global(tp->U.V22.tcindx, dp, depend);
  1365. X            global(tp->U.V22.tcelem, dp, depend);
  1366. X            break ;
  1367. X          case narray:
  1368. X            global(tp->U.V23.taindx, dp, depend);
  1369. X            global(tp->U.V23.taelem, dp, depend);
  1370. X            break ;
  1371. X          case nfileof:  case nsetof:
  1372. X            global(tp->U.V18.tof, dp, depend);
  1373. X            break ;
  1374. X          case nptr:
  1375. X            global(tp->U.V16.tptrid, dp, depend);
  1376. X            break ;
  1377. X          case nscalar:
  1378. X            global(tp->U.V17.tscalid, dp, depend);
  1379. X            break ;
  1380. X          case nbegin:
  1381. X            global(tp->U.V24.tbegin, dp, depend);
  1382. X            break ;
  1383. X          case nif:
  1384. X            global(tp->U.V31.tifxp, dp, depend);
  1385. X            global(tp->U.V31.tthen, dp, depend);
  1386. X            global(tp->U.V31.telse, dp, depend);
  1387. X            break ;
  1388. X          case nwhile:
  1389. X            global(tp->U.V32.twhixp, dp, depend);
  1390. X            global(tp->U.V32.twhistmt, dp, depend);
  1391. X            break ;
  1392. X          case nrepeat:
  1393. X            global(tp->U.V33.treptstmt, dp, depend);
  1394. X            global(tp->U.V33.treptxp, dp, depend);
  1395. X            break ;
  1396. X          case nfor:
  1397. X            ip = idup(tp->U.V34.tforid);
  1398. X            if (Member((unsigned)(ip->tup->tt), Conset[135]))
  1399. X                registervar(tp->U.V34.tforid);
  1400. X            global(tp->U.V34.tforid, dp, depend);
  1401. X            global(tp->U.V34.tfrom, dp, depend);
  1402. X            global(tp->U.V34.tto, dp, depend);
  1403. X            global(tp->U.V34.tforstmt, dp, depend);
  1404. X            break ;
  1405. X          case ncase:
  1406. X            global(tp->U.V35.tcasxp, dp, depend);
  1407. X            global(tp->U.V35.tcaslst, dp, depend);
  1408. X            global(tp->U.V35.tcasother, dp, depend);
  1409. X            break ;
  1410. X          case nchoise:
  1411. X            global(tp->U.V36.tchocon, dp, depend);
  1412. X            global(tp->U.V36.tchostmt, dp, depend);
  1413. X            break ;
  1414. X          case nwith:
  1415. X            global(tp->U.V37.twithvar, dp, depend);
  1416. X            global(tp->U.V37.twithstmt, dp, depend);
  1417. X            break ;
  1418. X          case nwithvar:
  1419. X            ip = typeof(tp->U.V38.texpw);
  1420. X            if (ip->U.V21.tuid == (struct S59 *)NIL)
  1421. X                ip->U.V21.tuid = mkvariable('S');
  1422. X            global(tp->U.V38.texpw, dp, depend);
  1423. X            break ;
  1424. X          case nlabstmt:
  1425. X            global(tp->U.V25.tstmt, dp, depend);
  1426. X            break ;
  1427. X          case neq:  case nne:  case nlt:  case nle:
  1428. X          case ngt:  case nge:
  1429. X            global(tp->U.V41.texpl, dp, depend);
  1430. X
  1431. X            global(tp->U.V41.texpr, dp, depend);
  1432. X            ip = typeof(tp->U.V41.texpl);
  1433. X            if ((ip == typnods.A[(int)(tstring)]) || (ip->tt == narray))
  1434. X                usecomp = true;
  1435. X            ip = typeof(tp->U.V41.texpr);
  1436. X            if ((ip == typnods.A[(int)(tstring)]) || (ip->tt == narray))
  1437. X                usecomp = true;
  1438. X            break ;
  1439. X          case nin:  case nor:  case nplus:  case nminus:
  1440. X          case nand:  case nmul:  case ndiv:  case nmod:
  1441. X          case nquot:  case nformat:  case nrange:
  1442. X            global(tp->U.V41.texpl, dp, depend);
  1443. X            global(tp->U.V41.texpr, dp, depend);
  1444. X            break ;
  1445. X          case nassign:
  1446. X            global(tp->U.V27.tlhs, dp, depend);
  1447. X            global(tp->U.V27.trhs, dp, depend);
  1448. X            break ;
  1449. X          case nnot:  case numinus:  case nuplus:  case nderef:
  1450. X            global(tp->U.V42.texps, dp, depend);
  1451. X            break ;
  1452. X          case nset:
  1453. X            global(tp->U.V42.texps, dp, depend);
  1454. X            break ;
  1455. X          case nindex:
  1456. X            global(tp->U.V39.tvariable, dp, depend);
  1457. X            global(tp->U.V39.toffset, dp, depend);
  1458. X            break ;
  1459. X          case nselect:
  1460. X            global(tp->U.V40.trecord, dp, depend);
  1461. X            break ;
  1462. X          case ncall:
  1463. X            global(tp->U.V30.tcall, dp, depend);
  1464. X            global(tp->U.V30.taparm, dp, depend);
  1465. X            break ;
  1466. X          case nid:
  1467. X            ip = idup(tp);
  1468. X            if (ip == (struct S61 *)NIL)
  1469. X                goto L555;
  1470. X            do {
  1471. X                ip = ip->tup;
  1472. X                if (ip == (struct S61 *)NIL)
  1473. X                    goto L555;
  1474. X            } while (!(Member((unsigned)(ip->tt), Conset[136])));
  1475. X            if (dp == ip) {
  1476. X                if (depend)
  1477. X                    tp->U.V43.tsym->U.V6.lused = true;
  1478. X            } else {
  1479. X                tp->U.V43.tsym->U.V6.lused = true;
  1480. X            }
  1481. X        L555:
  1482. X            ;
  1483. X            break ;
  1484. X          case ngoto:
  1485. X            if (!islocal(tp->U.V26.tlabel)) {
  1486. X                tp->U.V26.tlabel->U.V43.tsym->U.V9.lgo = true;
  1487. X                usejmps = true;
  1488. X                cklevel(tp->U.V26.tlabel);
  1489. X            }
  1490. X            break ;
  1491. X          case nbreak:  case npush:  case npop:  case npredef:
  1492. X          case nempty:  case nchar:  case ninteger:  case nreal:
  1493. X          case nstring:  case nnil:
  1494. X            break ;
  1495. X          default:
  1496. X            Caseerror(Line);
  1497. X        }
  1498. X        tp = tp->tnext;
  1499. X    }
  1500. X}
  1501. X
  1502. X void
  1503. Xrenamc()
  1504. X{
  1505. X    idptr    ip;
  1506. X    register cnames    cn;
  1507. X
  1508. X    {
  1509. X        cnames    B49 = cabort,
  1510. X            B50 = cwrite;
  1511. X
  1512. X        if ((int)(B49) <= (int)(B50))
  1513. X            for (cn = B49; ; cn = (cnames)((int)(cn)+1)) {
  1514. X                ip = mkrename('C', ctable.A[(int)(cn)]);
  1515. X                ctable.A[(int)(cn)]->istr = ip->istr;
  1516. X                if (cn == B50) break;
  1517. X            }
  1518. X    }
  1519. X}
  1520. X
  1521. X void
  1522. Xrenamp(tp, on)
  1523. X    treeptr    tp;
  1524. X    boolean    on;
  1525. X{
  1526. X    symptr    sp;
  1527. X
  1528. X    while (tp != (struct S61 *)NIL) {
  1529. END_OF_FILE
  1530. if test 30864 -ne `wc -c <'ptc.c.3'`; then
  1531.     echo shar: \"'ptc.c.3'\" unpacked with wrong size!
  1532. fi
  1533. # end of 'ptc.c.3'
  1534. fi
  1535. echo shar: End of archive 2 \(of 12\).
  1536. cp /dev/null ark2isdone
  1537. MISSING=""
  1538. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1539.     if test ! -f ark${I}isdone ; then
  1540.     MISSING="${MISSING} ${I}"
  1541.     fi
  1542. done
  1543. if test "${MISSING}" = "" ; then
  1544.     echo You have unpacked all 12 archives.
  1545.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1546. else
  1547.     echo You still need to unpack the following archives:
  1548.     echo "        " ${MISSING}
  1549. fi
  1550. ##  End of shell archive.
  1551. exit 0
  1552. -- 
  1553.  
  1554. Rich $alz            "Anger is an energy"
  1555. Cronus Project, BBN Labs    rsalz@bbn.com
  1556. Moderator, comp.sources.unix    sources@uunet.uu.net
  1557.